import { LOGIN, LOGOUT } from '@/store/actionsType/xyf/xyf-type'

const initState = {
    username: '',
    password: '',
    isLogin: false     //判断是否登录
}

export default function handleLogin(state = initState, action) {
    switch(action.type) {
        case LOGIN:     //登录
            return {
                ...state,
                username: action.data.username,
                password: action.data.password,
                isLogin: true
            }
        case LOGOUT:     //退出
            return {
                ...state,
                username: '',
                password: '',
                isLogin: false
            }
        default: 
            return state
    }
}